package com.tjtt.tdm.system.bean;

import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/**
 * 用户表
 * @author liangjy
 *
 */
public class Users extends AbstractUsers implements java.io.Serializable {
	private String roleName;
	private String orgNameLabel;
	private Long orgIdLabel;
	public String activeLabel;
	public String sexLabel;
	private String securityClassLabel;
	private String roleNameStr;
	private Set<Role> roles = new HashSet<Role>();//角色组
	private String lockFlagLabel;
	
	public Set<Role> getRoles() {
		return roles;
	}
	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}
	
	public String getRoleIdStr(){
		String roleIds = "";
		if(roles.size()>0){
			for(Role role : roles){
				roleIds+=role.getRoleId()+",";
			}
			roleIds = roleIds.substring(0,roleIds.length()-1);
		}	
		return roleIds;
	}

 
	public String getLockFlagLabel(){
		String lockFlagLabel = "";
		if(this.getLockFlag()!=null){
			if(this.getLockFlag().equals("1"))
				lockFlagLabel = "锁定";
			if(this.getLockFlag().equals("0"))
				lockFlagLabel = "未锁定";
		}
		return lockFlagLabel;
	}
	
	public String getActiveLabel() {
		String label = "";
		if(this.getActive()!=null){			
			if(this.getActive().intValue() == 1)
				label = "有效";
			if(this.getActive().intValue() == 0)
				label = "外出试验";
		}
		return label;
	}
	
	public String getSexLabel() {
		String sexlabel = "";
		if(this.getSex()!=null){
			if(this.getSex().intValue() == 1)
				sexlabel = "男";
			if(this.getSex().intValue() == 0)
				sexlabel = "女";
		}
		return sexlabel;
	}
	public Long getRoleId() {
		return 1L;
	}
	public String getRoleNameStr(){
		String roleNameStr = "";
		if(roles.size()>0){
			Iterator<Role> it = roles.iterator();   
			while (it.hasNext()) {   
				roleNameStr += it.next().getRolename();  
				roleNameStr += ",";
			}   
			roleNameStr = roleNameStr.substring(0, roleNameStr.length()-1);
		}
		return roleNameStr;
	}
	public String getRoleName() {
		return "roleName";
	}
	public Users() {
	}

	/** minimal constructor */
	public Users(Long userid) {
		super(userid);
	}

	/** full constructor */
	public Users(Long userid, Role role, String loginname,
			String psw, Long active, String username, String fixedPhone,
			String mobile, String email, String userdesc, Long securityClass,
			Organization organization,String delFlag,String lockFlag,
			Date lockTime,Date pwdEditTime,Long sex,String companyTel,
			String address,String imgPath,String signPath,
			String imgAddress,String signAddress,String stampPath,
			String stampAddress,String certificatePath,String certificateAddress,Long pwdFailCount,
			Date loginTime,String jobName) {
		super(userid, role, loginname, psw, active, username,
				fixedPhone, mobile, email, userdesc, securityClass,
				organization,delFlag,lockFlag,lockTime,pwdEditTime,
				sex,companyTel,address,imgPath,signPath,
				imgAddress,signAddress,stampPath,stampAddress,certificatePath,certificateAddress,pwdFailCount,loginTime,jobName);
	}
	public String getOrgNameLabel() {
		if(this.getOrganization() == null){
			return null;
		}
		return this.getOrganization().getOrgName();
	}
	public Long getOrgIdLabel() {
		if(this.getOrganization() == null){
			return null;
		}
		return this.getOrganization().getOrgId();
	}

}
